﻿/*using System;
using System.Collections.Generic;
using System.Text;

using System.Web;
using System.Net;
using System.Runtime.Serialization.Json;

import java.io.BufferedReader; 
import java.io.IOException; 
import java.io.InputStreamReader; 
import java.net.HttpURLConnection; 
import java.net.URL; 
import java.sql.Connection;
import java.io.StringWriter;


namespace HTSwitchServerNamespace
{

        
//http://code.google.com/p/google-gson/ 

import com.google.gson.stream.JsonWriter;

public class locate 
{

    public HttpURLConnection requestLatlongFromGoogle() throws IOException 
    {
        //prepare parameters for POST method 
        StringWriter sw = new StringWriter();
        JsonWriter jw = new JsonWriter(sw);
        
        try 
        {
            jw.beginObject();
            jw.name("host").value("maps.google.com"); jw.name("version").value("1.1.0"); jw.name("request_address").value(true);
            jw.name("cell_towers");
            jw.beginArray().beginObject();
            jw.name("cell_id").value(18881); jw.name("location_area_code").value(1); jw.name("mobile_network_code").value(803); jw.name("mobile_country_code").value(405);
            jw.endObject().endArray().endObject();
        } 
        finally 
        {
            try 
            { 
                jw.close(); 
            } 
            catch (IOException ioe) 
            {}
    
            try 
            { 
                 sw.close(); 
            } 
            catch (IOException ioe) 
            {
        }
        
    } 
    
    final String JsonParams? = sw.toString();
    
    // String JsonParams? = "{}";
    System.out.println(JsonParams?); final String GoogleLocJsonUrl? = "http://www.google.com/loc/json";
    
    //post request URL url = null; HttpURLConnection conn = null; url = new URL(GoogleLocJsonUrl?); conn = (HttpURLConnection) url.openConnection(); conn.setConnectTimeout((int) 30e3); conn.setReadTimeout((int) 30e3);
    conn.setDoOutput(true); conn.setRequestMethod("POST"); conn.getOutputStream().write(JsonParams?.getBytes()); conn.getOutputStream().flush(); conn.getOutputStream().close(); int resCode = conn.getResponseCode();
    return conn;
}
public static void readData(HttpURLConnection connection)
{ 
        HttpURLConnection conn = connection;
        
    try 
    { 
        BufferedReader? in = new BufferedReader?(new InputStreamReader?(conn.getInputStream())); String decodedString;
        while ((decodedString = in.readLine()) != null) 
        {
            System.out.println(decodedString);
        } 
        in.close();
    } 
    catch (IOException e) 
    {        
    
    // TODO Auto-generated catch block e.printStackTrace();
    }
} 

public static void main(String a)
{
    locate loc = new locate(); 
    try 
    {
      HttpURLConnection con = loc.requestLatlongFromGoogle(); readData(con);
    } 
    catch (IOException e) 
    {
        // TODO Auto-generated catch block e.printStackTrace();
    }
}

}



    namespace GoogleMapsSample
{
    public class GoogleMaps
    {

        /// <summary>
        /// 
        /// </summary>
        /// <param name="address"></param>
        /// <returns></returns>
        public static GeoResponse GetGeoCodedResults(string address)
        {
            string url = string.Format(
                    "http://maps.google.com/maps/api/geocode/json?address={0}&region=dk&sensor=false",
                    HttpUtility.UrlEncode(address)
                    );
            var request = (HttpWebRequest)HttpWebRequest.Create(url);
            request.Headers.Add(HttpRequestHeader.AcceptEncoding, "gzip,deflate");
            request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
            DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(GeoResponse));
            var res = (GeoResponse)serializer.ReadObject(request.GetResponse().GetResponseStream());
            return res;
        }


    }
}
*/